package com.ttwl.www.app.homepage;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.ttwl.www.app.R;

/**
 * Created by Administrator on 2017/10/27 0027.
 */


//  这地方新建的时候，所继承的是  Adapter <vh>V7包下的Adapter
public class FreeAdapter extends RecyclerView.Adapter<FreeAdapter.LinearViewHolder> {

    private Context mContext;

    public FreeAdapter(Context context){
        this.mContext = context;
    }

    @Override
    public FreeAdapter.LinearViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_free_item,parent,false));
    }

    @Override
    public void onBindViewHolder(FreeAdapter.LinearViewHolder holder, int position) {

        holder.freeTitle.setText("预防蛀牙有哪些方法");
        holder.freeTeacher.setText("主讲老师：金老师");
        holder.freeTime.setText("开课时间：2088-08-08");
        holder.freeContent.setText("免费");
        holder.freeNum.setText("998人想学");
//        Glide.with(mContext).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1508896566&di=d7815dee0fb3753fd59f7915e5702420&imgtype=jpg&er=1&src=http%3A%2F%2Fimg2.3lian.com%2F2014%2Ff4%2F209%2Fd%2F23.jpg").into(holder.imageView);

    }

    //    这地方是列表长度
    @Override
    public int getItemCount() {
        return 30;
    }

    class LinearViewHolder extends RecyclerView.ViewHolder{

        //        在这里声明布局中的控件
        protected ImageView imageView;
        private TextView freeTitle,freeTeacher,freeTime,freeContent,freeNum;



        public LinearViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.free_img);
            freeTitle = (TextView) itemView.findViewById(R.id.free_title);
            freeTeacher = (TextView) itemView.findViewById(R.id.free_teacher);
            freeTime = (TextView) itemView.findViewById(R.id.free_time);
            freeContent = (TextView) itemView.findViewById(R.id.free_content);
            freeNum = (TextView) itemView.findViewById(R.id.free_num);

        }
    }
}
